﻿using Microsoft.Extensions.DependencyInjection;

namespace 依赖注入传染;

class Program
{
    static void Main(string[] args)
    {
        ServiceCollection services = new ServiceCollection();
        services.AddScoped<Controller>();
        services.AddScoped<ILog, LogImpl>();
        services.AddScoped<IStorage, StorageImpl>();
        services.AddScoped<IConfig, ConfigImpl>();
        using (ServiceProvider sp = services.BuildServiceProvider())
        {
            var myController = sp.GetRequiredService<Controller>();
            myController.TestMethod();
        }
    }
}


